<?php
/*** 
 *
 *
 *
 **/
require_once '../db/db.php';
require_once '../util/auth.php';
require_once '../util/perm.php';

// not liking this, maybe optionals in array?
function addUser( $name, $pass, $email, $pgname = "user", $timezone = 0, $avatar = '', $botcheck = 1, $rank = 0, $karma = 0 ) {
  try {
    $db = openDbConn();

    // validate for spaces and stuff like that
    $user = $db->quote($name);
    $pass = $db->quote($pass);
    $email = $db->quote($email);
    $pgname = $db->quote($pgname);
    $timezone = $db->quote($timezone);
    $avatar = $db->quote($avatar);
    $botcheck = $db->quote($botcheck);
    $rank = $db->quote($rank);
    $karma = $db->quote($karma);
    $time = $db->quote(time());

    $db->beginTransaction();
    $db->exec("INSERT INTO user (name, pass, mail, permgrp, joindate) 
                  VALUES ($user, $pass, $email, (SELECT id FROM permgroup WHERE name = ${pgname}), ${time} );");
    $db->commit();

  } catch ( PDOException $e ) {
    $db->rollback();
    print "ERROR: " . $e->getMessage() . "<br />";
    die();
  }
};
function deleteUserByName( $name ) {
  if( !authentic() )
    return ERR_UNAUTHENTIC;
  if( !hasPerm('user.delete') )
    return MSG_UNAUTHORIZED;
 
  try {
    $db = openDbConn();

    // validate for spaces and stuff like that
    $uid = 
    $db->beginTransaction();
    $db->exec(";");
    $db->commit();

  } catch ( PDOException $e ) {
    $db->rollback();
    print "ERROR: " . $e->getMessage() . "<br />";
    die();
  }
};
function deleteUserByUid( $uid ) { 
  if( !authentic() )
    return ERR_UNAUTHENTIC;
  if( !hasPerm('user.delete') )
    return MSG_UNAUTHORIZED;

  try {
    $db = openDbConn();

    // validate for spaces and stuff like that
    $uid = 
    $db->beginTransaction();
    $db->exec(";");
    $db->commit();

  } catch ( PDOException $e ) {
    $db->rollback();
    print "ERROR: " . $e->getMessage() . "<br />";
    die();
  }
};

function setUserByUid( $uid, $options = array() ) { };
function setUserByName( $name, $options = array() ) { };

function newPermGroup( $name ) { };
function setPermGroup( $name, $perm ) { };

function setUserBlock( $fromUid, $toUid ) { };
function unsetUserBlock( $fromUid, $toUid ) { };
function addGlobalBlock( $uid ) { };
function unsetGlobalBlock( $uid ) { };

function addFriend( $fromUid, $toUid ) { };
function friendConfirm( $fromUid, $toUid ) { };

function validateSession( $uuid, $ip ) { };


?>
